package cn.wolfcode.shop.server.service.impl;

import cn.wolfcode.shop.api.domain.OrderProduct;
import cn.wolfcode.shop.api.service.IOrderProductService;
import cn.wolfcode.shop.server.mapper.OrderProductMapper;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


@Service
public class OrderProductServiceImpl implements IOrderProductService{

    @Autowired
    private OrderProductMapper orderProductMapper;

    @Override
    public int save(OrderProduct orderProduct) {
        return orderProductMapper.insert(orderProduct);
    }

    @Override
    public int update(OrderProduct orderProduct) {
        return orderProductMapper.updateByPrimaryKey(orderProduct);
    }

    @Override
    public OrderProduct get(Long id) {
        return orderProductMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<OrderProduct> selectAll() {
        return orderProductMapper.selectAll();
    }

    @Override
    public List<OrderProduct> selectProductByOrderId(Long orderId) {
        return orderProductMapper.selectProductByOrderId(orderId);
    }

    @Override
    public int countProductAmountByOrderId(Long id) {
        return orderProductMapper.countProductAmountByOrderId(id);
    }
}
